#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <queue>
using namespace std;

class Solution
{
private:
    int map[8][8];
    int size;
    string s;
    pair<int, int> begin;
    pair<int, int> end;
    vector<pair<int, int>> dir;

public:
    Solution(string s) : s(s)
    {
        begin = {s[0] - 'a', s[1] - '1'};
        end = {s[3] - 'a',
               s[4] - '1'};
        dir = {{-1, -2}, {-1, 2}, {-2, -1}, {-2, 1}, {1, -2}, {1, 2}, {2, -1}, {2, 1}};
        size = 8;
    }

    void ResetMap()
    {
        for (int i = 0; i < 8; i++)
        {
            memset(map[i], 0, sizeof(map[i]));
        }
    }

    string getAns()
    {
        ResetMap();
        // solution at here
        queue<pair<int, int>> Q;
        Q.push(begin);
        while (!Q.empty())
        {
            pair<int, int> tmp = Q.front();
            Q.pop();
            if (tmp == end)
            {
                break;
            }
            for (int i = 0; i < 8; i++)
            {
                int x = tmp.first + dir.at(i).first;
                int y = tmp.first + dir.at(i).second;
                pair<int, int> now = {x, y};
                if (x >= 0 && x < size && y >= 0 && y < size && map[x][y] == 0 && now != begin)
                {
                    Q.push(now);
                    map[now.first][now.second] = map[tmp.first][tmp.second] + 1;
                }
            }
        }

        return getAnsStr();
    }

    string getAnsStr()
    {
        return "To get from " + s.substr(0, 2) + " to " + s.substr(3, 2) + " takes " + to_string(map[end.first][end.second]) + " knight moves.";
    }
};

int main()
{
    while (1)
    {
        string s;
        cin >> s;
        Solution solu = Solution(s);
        string ans = solu.getAns();
        cout << ans << endl;
    }

    return 0;
}